package com.agileai.wm.module.workgroup.handler;

import com.agileai.domain.DataParam;
import com.agileai.domain.DataRow;
import com.agileai.hotweb.annotation.PageAction;
import com.agileai.hotweb.controller.core.SimpleHandler;
import com.agileai.hotweb.domain.FormSelect;
import com.agileai.hotweb.domain.FormSelectFactory;
import com.agileai.hotweb.renders.AjaxRenderer;
import com.agileai.hotweb.renders.LocalRenderer;
import com.agileai.hotweb.renders.ViewRenderer;
import com.agileai.wm.module.workgroup.service.WmGroupTreeManage;

/**
 * generated by miscdp
 */
public class RelPropertieEditHandler extends SimpleHandler{
	public RelPropertieEditHandler(){
		super();
	}
	
	public ViewRenderer prepareDisplay(DataParam param) {
		this.setAttributes(param);
		WmGroupTreeManage service = this.lookupService(WmGroupTreeManage.class);
		DataRow record = service.findDetail(param);
		this.setAttributes(record);
		FormSelect empJob = FormSelectFactory.create("EMP_JOB_TYPE").addSelectedValue(getAttributeValue("EMP_JOB", "Participant"));
		this.setAttribute("EMP_JOB", empJob);
		return new LocalRenderer(getPage());
	}
	
	@PageAction
	public ViewRenderer updateRelProperties(DataParam param){
		String responseText = FAIL;
		try {
			WmGroupTreeManage service = this.lookupService(WmGroupTreeManage.class);
			service.updateRelProperties(param);
			responseText = SUCCESS;
		} catch (Exception e) {
			log.error(e.getLocalizedMessage(), e);
		}
		return new AjaxRenderer(responseText);
	}
}
